/**
 * @author iurie
 * Methods for adding dynamic content to page
 */


window.onload = initPage;


function initPage() {
	
	var menuList = document.getElementById("menu").getElementsByTagName("a");
	
	for ( var int = 0; int < menuList.length; int++) {		
		var currentItem =menuList[int];
		currentItem.onmouseover = showHint;
		currentItem.onmouseout = hideHint;
		currentItem.onclick = loadViaAjax;
	}
	
}


function showHint() {
	var productInfo = document.getElementById("product");
	productInfo.innerHTML = "All products";
}

function hideHint() {
	var productInfo = document.getElementById("product");
	productInfo.innerHTML = "";
}

function loadViaAjax() {
	var selectedItem = this.title;
	
	var request = createRequest();
//	alert("load ajax");
	request.onreadystatechange = updateText;
	request.open("GET", "testAjax.htm", true);
	request.send(null);
}

function updateText() {
	if (request.readyState == 4) {
		if (request.status == 200) {
			
			document.getElementById("product").innertHTML = request.responseText;
		}
	}
}
